package sse.ustc.cc.adapter;

import java.util.ArrayList;

import sse.ustc.cc.activity.R;
import sse.ustc.cc.util.ClassInfo;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MyListAdp extends BaseAdapter {
	private ArrayList<Object> classList;
	private Context mContext;
	private final static String[] jieshu = { "第一节","第二节", "第三节", "第四节", "第五节", "第六节",
		"第七节", "第八节","第九节","第十节", "第十一节", "第十二节"};
	
	
	public MyListAdp(ArrayList<Object> classList,
			 Context mContext) {
		super();
		this.classList = classList;
		this.mContext = mContext;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return classList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return classList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ClassInfo classInfo = (ClassInfo) classList.get(position);
		ViewHolder holder = null;
		if(convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(mContext).inflate(R.layout.day_list_item, null);
			holder.text1 = (TextView) convertView.findViewById(R.id.jieshu);
			holder.text2 = (TextView) convertView.findViewById(R.id.class_info);
			
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		holder.text1.setText(jieshu[position]);
		holder.text2.setText(classInfo.getClassname() + "\n" + classInfo.getClassRoom());
	
		return convertView;
	}
	
	protected class ViewHolder {
		TextView text1;
		TextView text2;
	}

}
